package com.cmas.platform.controller;

import java.util.Arrays;
import java.util.List;
import java.util.HashMap;
import java.util.Map;
import com.aidex.common.annotation.DataSource;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.aidex.common.core.page.TableDataInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.enums.DataSourceType;
import com.aidex.common.utils.poi.ExcelUtil;
import com.aidex.common.core.controller.BaseController;
import com.aidex.framework.cache.DictUtils;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.cmas.platform.domain.ApproveRecord;
import com.cmas.platform.service.ApproveRecordService;


/**
 * 审核记录表Controller
 * @author su
 * @email 1218819874@qq.com
 * @date 2023-03-13
 */
@DataSource(value = DataSourceType.SLAVE)
@RestController
@RequestMapping("/platform/approveRecord")
public class ApproveRecordController extends BaseController  {

    @Autowired
    private ApproveRecordService approveRecordService;

    /**
     * 查询审核记录表列表
     */
    @GetMapping("/list")
    public R<TableDataInfo> list(ApproveRecord approveRecord) {
        startPage();
        List<ApproveRecord> list = approveRecordService.selectApproveRecordList(approveRecord);
        return R.data(getDataTable(list));
    }



    /**
     * 获取审核记录表详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:approveRecord:query')")
    @GetMapping(value = "/{id}")
    public R<ApproveRecord> detail(@PathVariable("id") String id) {
        return R.data(approveRecordService.getById(id));
    }

    /**
     * 新增审核记录表
     */
    @PreAuthorize("@ss.hasPermi('platform:approveRecord:add')")
    @Log(title = "审核记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  ApproveRecord approveRecord) {
        return R.data(approveRecordService.save(approveRecord));
    }

    /**
     * 修改审核记录表
     */
    @PreAuthorize("@ss.hasPermi('platform:approveRecord:edit')")
    @Log(title = "审核记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated ApproveRecord approveRecord) {
        return R.data(approveRecordService.updateById(approveRecord));
    }

    /**
     * 删除审核记录表
     */
    @PreAuthorize("@ss.hasPermi('platform:approveRecord:remove')")
    @Log(title = "审核记录表", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids) {
        return R.data(approveRecordService.removeByIds(Arrays.asList(ids)));
    }


    /**
     * 导出审核记录表列表
     */
    @PreAuthorize("@ss.hasPermi('platform:approveRecord:export')")
    @Log(title = "审核记录表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(ApproveRecord approveRecord) {
        List<ApproveRecord> list = approveRecordService.selectApproveRecordList(approveRecord);
        ExcelUtil<ApproveRecord> util = new ExcelUtil<ApproveRecord>(ApproveRecord.class);
        return util.exportExcel(list, "审核记录表数据");
    }
	
    /**
     * 根据字典类型查询字典数据信息等其他自定义信息
     */
    @GetMapping(value = "/getInitData/{dictTypes}")
    public R getInitData(@PathVariable String dictTypes) {
        Map<String, Object> dataMap = new HashMap<String, Object>();
        dataMap.putAll(DictUtils.getMultiDictList(dictTypes));
        return R.data(dataMap);
    }


    // ***用户系统位置戳****



    /**
     * 查询审核记录表列表
     */
    @GetMapping("/getList")
    public R<TableDataInfo> getList(ApproveRecord approveRecord) {
        List<ApproveRecord> list = approveRecordService.selectApproveRecordList(approveRecord);
        return R.data(getDataTable(list));
    }

}
